package rwt.msg.internal;

import java.util.*;

import rail.mtl.ada_native.NaturalListTypePkg.naturalListPkg.*;

public class AdaTypeUtil
{
	public static List<Integer> convertAdaListToJava(ListType adaList)
	{
		final int count = naturalListPkg_Package.getCount(adaList);
		List<Integer> intList = new ArrayList<Integer>(count + 1);
		
		listIteratorType itr = naturalListPkg_Package.MoveFront(adaList);
		for (int i = 0; i < count; i++)
		{
			int val = naturalListPkg_Package.GetCurrent(itr);
			intList.add(i, val);
			itr = naturalListPkg_Package.MoveNext(itr);
		}
		
		return intList;
	}
	
	public static ListType convertJavaListToAda(Collection<Integer> javaList)
	{
		final int count = javaList.size();
		ListType adaList = new ListType();
		
		for (int val : javaList)
		{
			naturalListPkg_Package.AddEnd(adaList, val);
		}
		
		assert (count == naturalListPkg_Package.getCount(adaList));
		
		return adaList;
	}
}
